<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>页面电子时钟</title>
    <style>
        p {
            font-size: 50px;
            line-height: 25px;
        }
    </style>

</head>

<body>
    <p id="oclick">在这里显示时间</p>
    <script>
        function showTime() {
            var nowTime = new Date()
            var ps = document.getElementById('oclick')
            ps.innerHTML = nowTime.getFullYear() + '年' +
                (nowTime.getMonth() + 1) + '月' + nowTime.getDay() + '日' +
                (nowTime.getHours() < 10 ? '0' + nowTime.getHours() : nowTime.getHours()) + ':' +
                (nowTime.getMinutes() < 10 ? '0' + nowTime.getMinutes() : nowTime.getMinutes()) + ':' +
                (nowTime.getSeconds() < 10 ? '0' + nowTime.getSeconds() : nowTime.getSeconds())
            setTimeout('showTime();', 1000)
        }
        showTime()
    </script>
</body>

</html>